package com.dddpeter.app.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 评论实体类
 */
@TableName("comments")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Comment {
    
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;
    
    @TableField("article_id")
    private Long articleId;
    
    @TableField("parent_id")
    private Long parentId; // 父评论ID，用于回复功能
    
    @TableField("nickname")
    private String nickname; // 评论者昵称
    
    @TableField("avatar")
    private String avatar; // 评论者头像
    
    @TableField("content")
    private String content; // 评论内容
    
    @TableField("like_count")
    private Integer likeCount = 0; // 点赞数
    
    @TableField("is_anonymous")
    private Boolean isAnonymous = true; // 是否匿名评论
    
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;
    
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;
    
    // 子评论列表（非数据库字段）
    @TableField(exist = false)
    private List<Comment> replies;
    
    // 是否已点赞（非数据库字段）
    @TableField(exist = false)
    private Boolean isLiked = false;
}
